-- Copyright (c) 2025 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

local class = require 'mc.class'
local log = require 'mc.logging'
local certificate = require 'domain.certificate'

local trusted_component = class()

function trusted_component:ctor(chassis_id, device, inventory_path, type)
    self.m_chassis_id = chassis_id
    self.m_mdb_name = device.mdb_name
    self.m_device_name = device.device_name
    self.m_inventory_path = inventory_path
    self.m_type = type
    self.m_cert_collection = {}
end

function trusted_component:init()

end

function trusted_component:add_certificate(slot_id, cert_info)
    if self.m_cert_collection[slot_id] then
        self.m_cert_collection[slot_id] = nil
    end

    self.m_cert_collection[slot_id] = certificate.new(self.m_chassis_id, self.m_mdb_name, cert_info)

    return self.m_cert_collection[slot_id]
end

return trusted_component